package com.example.fang.demodruid.controller;

import com.example.fang.demodruid.entity.admin.CourseRespBO;
import com.example.fang.demodruid.entity.admin.StudentRespBO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/admin")
public class AdminController {

    @RequestMapping("/index")
    public String index(){
        return "/admin/index";
    }

    @RequestMapping("/list")
    public String list(){
        return "/admin/list";
    }

    @RequestMapping("/stuList")
    public String stuList(){
        return "/admin/stuList";
    }


    @RequestMapping("/listJson")
    @ResponseBody
    public Map<String,Object> listJson(){
        Map<String,Object> res=new HashMap<>();
        List<CourseRespBO> list=new ArrayList<>();
        for(int i=0;i<10;i++){
            CourseRespBO courseRespBO=new CourseRespBO();
            courseRespBO.setId(i);
            courseRespBO.setCourseName("课程名称"+i);
            courseRespBO.setCoursePrice("12"+i);
            courseRespBO.setName("测试");
            courseRespBO.setOrderDate("2022-09-12");
            courseRespBO.setQqNo("3232"+i);
            courseRespBO.setWechatMark("微信备注"+i);
            courseRespBO.setWechatNo("786868"+i);
            list.add(courseRespBO);
        }
        res.put("code",0);
        res.put("msg","success");
        res.put("data",list);
        return res;
    }


    @RequestMapping("/stulistJson")
    @ResponseBody
    public Map<String,Object> stulistJson(){
        Map<String,Object> res=new HashMap<>();
        List<StudentRespBO> list=new ArrayList<>();
        for(int i=0;i<10;i++){
            StudentRespBO studentRespBO=new StudentRespBO();
            studentRespBO.setId(i);
            studentRespBO.setName("测试");
            studentRespBO.setAddress("湖南省"+i);
            studentRespBO.setPhone("18380458545");
            list.add(studentRespBO);
        }
        res.put("code",0);
        res.put("msg","success");
        res.put("data",list);
        return res;
    }

}
